#include <stdio.h>
#include <stdlib.h>

#define INITSIZE 10

struct LinearList
{
  int *data;
  int MaxSize;
  int length;
};

void InitList(struct LinearList *ll);
void IncreaseSize(struct LinearList *ll, int length);

int main()
{
  struct LinearList ll;
  InitList(&ll);
  IncreaseSize(&ll, 5);

  printf("length = %d\n", ll.length);
  printf("MaxSize = %d\n", ll.MaxSize);
  return 0;
}

void InitList(struct LinearList *ll)
{
  ll->data = (int *)malloc(INITSIZE * sizeof(int)); // 动态分配
  ll->length = 0;
  ll->MaxSize = INITSIZE;
}

void IncreaseSize(struct LinearList *ll, int length)
{
  int *p = ll->data;
  ll->data = malloc((ll->MaxSize + length) * sizeof(int));
  for (int i = 0; i < ll->length; i++)
  {
    ll->data[i] = p[i];
  }
  ll->MaxSize = ll->MaxSize + length;
  ll->length = ll->length + length;
  free(p);
}